package chapter14;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : DuJiabao
 * @Date : 2021/2/25 11:52
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class getClassTest {
  public static void main(String[] args) {
    List<Integer> list = new ArrayList<>();
    System.out.println(list.getClass());  // 会返回实际上的类，而不是接收它的接口
  }

  @Test
  public void test() {
    try {
      Class<?> list = Class.forName("chapter14.ShowMethods");
      for (Method method : list.getMethods()) {
        System.out.println(method.getName());
      }

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
}
